package jobhunter.tool;

import java.security.MessageDigest;
import org.springframework.security.crypto.codec.Hex;

public class SecurityUtils 
{
    private static String encode(String credentials, String mode) 
    {
        try 
        {
            MessageDigest md = (MessageDigest) MessageDigest.getInstance(mode).clone();
            md.update(credentials.getBytes());
            return new String(Hex.encode(md.digest()));
        }
        catch (Exception ex)
        {
            throw new RuntimeException("Could not encode credentials", ex);
        }
    }

    public static String myEncode(String credentials) 
    {
        return encode(credentials+"mysupersalt", "SHA-256");
    }
}